How to convert a column in a dataframe to a numeric value based on a specific code